import http from "../request";
const apibase = "/api/StdOperation"
import qs from 'qs'

//查询工序
var getStdOperationList = function (data) {
	return new Promise((resolve, reject) => {
		http.post(apibase + `/GetStdOperationList`, data)
			.then(res => {
				resolve(res)
			})
			.catch(error => {
				reject(error);
			})
	});
}
//新增工序
var insStdOperation = function (data) {
	return new Promise((resolve, reject) => {
		http.post(apibase + `/InsStdOperation`, data)
			.then(res => {
				resolve(res)
			})
			.catch(error => {
				reject(error);
			})
	});
}
//修改工序
var updStdOperation = function (data) {
	return new Promise((resolve, reject) => {
		http.post(apibase + `/UpdStdOperation`, data)
			.then(res => {
				resolve(res)
			})
			.catch(error => {
				reject(error);
			})
	});
}
//删除工序
var delStdOperation = function (data) {
	return new Promise((resolve, reject) => {
		http.post(apibase + `/DelStdOperation`, data)
			.then(res => {
				resolve(res)
			})
			.catch(error => {
				reject(error);
			})
	});
}

//查询工序已关联工作集
var getStdOperationListToStdOperationID = function (data) {
	return new Promise((resolve, reject) => {
		http.post(apibase + `/GetStdOperationListToStdOperationID`, data)
			.then(res => {
				resolve(res)
			})
			.catch(error => {
				reject(error);
			})
	});
}

//工序关联工作集
var insJobOperationRelations = function (update, data) {
	return new Promise((resolve, reject) => {
		http.post(apibase + `/InsJobOperationRelations?globalUpdates=${update}`, data)
			.then(res => {
				resolve(res)
			})
			.catch(error => {
				reject(error);
			})
	});
}

//工序取消关联工作集
var delJobOperationRelations = function (update, data) {
	return new Promise((resolve, reject) => {
		http.post(apibase + `/DelJobOperationRelations?globalUpdates=${update}`, data)
			.then(res => {
				resolve(res)
			})
			.catch(error => {
				reject(error);
			})
	});
}

//下载工序模板
var stdOperationTemplateDownload = function (data) {
	return new Promise((resolve, reject) => {
		http
			.post(apibase + `/StdOperationTemplateDownload`, data)
			.then((res) => {
				resolve(res);
			})
			.catch((error) => {
				reject(error);
			});
	});
};

//导入工序模板
var importStdOperation = function (data) {
	return new Promise((resolve, reject) => {
		http
			.Filepost(apibase + `/ImportStdOperation`, data)
			.then((res) => {
				resolve(res);
			})
			.catch((error) => {
				reject(error);
			});
	});
};
export {
	delJobOperationRelations, importStdOperation, stdOperationTemplateDownload,
	getStdOperationList, insStdOperation, updStdOperation, delStdOperation, insJobOperationRelations, getStdOperationListToStdOperationID
}
